#ifndef SFMLWINDOW_H
#define SFMLWINDOW_H

#include <SFML/Graphics.hpp>
#include <QtWidgets>
#include <QDebug>

#include "MassagesTypes.h"

#define WIDTH   600
#define HEIGHT  600

class Panzer {
public:
    Panzer(sf::Int16 color);

    sf::Texture texture;
    sf::Sprite  sprite;

    sf::Texture gunTexture;
    sf::Sprite  gunSprite;

    sf::Int8    hp;
    sf::Int16   color;

    void render(sf::RenderWindow* w);
};


class SFMLWindow : public QWidget, public sf::RenderWindow
{
    Q_OBJECT

public:
    SFMLWindow(QWidget *parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0);

    virtual void OnInit();
    virtual void OnUpdate();
    virtual QPaintEngine* paintEngine() const;
    virtual void showEvent(QShowEvent*);
    virtual void paintEvent(QPaintEvent*);
    void checkInput();

    void attack();

    QTimer  myTimer;
    QTimer  refreshTimer;
    int     updTime;
    bool    myInitialized;

    bool    refreshed;

    Panzer*  myTank;
    sf::Int16 my_color;

    sf::Int16 id_counter;

    sf::Sprite shootSprite;
    sf::Sprite bgSprite;

    std::vector<Panzer*>    tanks;
    std::vector<shoot>      shoots;

public slots:

    void start();
    void leave();

    void changeColor(sf::Int16 col);
    void tankHere(tankInfo tank);
    void shootHere(shoot sh);
    void refreshWeapon();

signals:

    void tankOut(tankInfo tank);
    void shootOut(shoot sh);

};

#endif // SFMLWINDOW_H
